package models

import (
	"gorm.io/gorm"
	"server/basic/config"
	"time"
)

type Medicine struct {
	Id           uint           `gorm:"column:id;type:bigint UNSIGNED;primaryKey;not null;" json:"id"`
	MedicineName string         `gorm:"column:medicine_name;type:varchar(255);comment:处方;not null;" json:"medicine_name"` // 处方
	DocId        uint           `gorm:"column:doc_id;type:bigint UNSIGNED;not null;default:0;" json:"doc_id"`
	UserId       uint           `gorm:"column:user_id;type:bigint UNSIGNED;not null;default:0;" json:"user_id"`
	Status       uint           `gorm:"column:status;type:int UNSIGNED;comment:审核状态：1：审核通过 2：审核未通过;not null;default:0;" json:"status"` // 审核状态：1：审核通过 2：审核未通过
	Price        uint           `gorm:"column:price;type:int UNSIGNED;comment:价格;not null;" json:"price"`                                         // 价格
	CreatedAt    time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt    time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt    gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (m *Medicine) TableName() string {
	return "medicine"
}
func (m *Medicine) UpdateMedicine() error {
	return config.DB.Where("id = ?", m.Id).Updates(&m).Error
}
